package com.czk.protocol.dubbo;

import com.czk.framework.Invocation;
import com.czk.framework.Protocol;
import com.czk.framework.URL;

/**
 * dubbo实现
 *
 * @Author:ChenZhangKun
 * @Date: 2021/4/15 15:41
 */
public class DubboProtocol implements Protocol {
    private NettyClient nettyClient;

    @Override
    public void start(URL url) {
        new NettyServer().start(url.getHostname(), url.getPort());
    }

    @Override
    public String send(URL url, Invocation invocation) {
        if (nettyClient == null) {
            nettyClient = new NettyClient();
        }
        return nettyClient.send(url.getHostname(), url.getPort(), invocation);
    }
}
